<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AdminBaseController extends Controller
{
    public function __construct(){
    }
    
    public function success($data){
        $message = !empty($data['message']) ? $data['message'] : config('error_code.code')[200];
        unset($data['message']);
        return response()->json([
            'status' => true,
            'code'   => 200,
            'message'=> $message,
            'data'   => $data
        ]);
    }
    
    public function failed($code, $data){
        $message = !empty($data['message']) ? $data['message'] : config('error_code.code')[200];
        unset($data['message']);
        return response()->json([
            'status' => false,
            'code'   => $code,
            'message'=> $message,
            'data'   => $data
        ]);
    }
    
    public function correct($message, $url){
        return view('errors/correct',['message'=>$message,'url'=>$url]);
    }
    
    public function error($code, $message, $url){
        return view('errors/error',['code'=>$code,'message'=>$message,'url'=>$url]);
    }
}
